<template>
	<uni-collapse accordion="true">
		<block v-for="(Item,Index) in dataList" :key="Index">
			<uni-collapse-item v-if="Item.c" :title="Item.t" @click="lastClick(Item,Index)" :open="Item.o"
				:showbtn="Item.vd" @openVideo="openVideo(Item)" :gdt="Item.gdt  " :active="active">
				<Tree class="rr" :dataList="Item.c"></Tree>
			</uni-collapse-item>
			<!-- <view v-else class="text11" @click="lastClick(Item,Index)">
				{{Item.t}}
			</view> -->
		</block>
	</uni-collapse>
</template>

<script>
	import uniCollapse from "@/components/uni-collapse/uni-collapse.vue";
	import uniCollapseItem from "@/components/uni-collapse-item/uni-collapse-item.vue";
	import Tree from "@/components/Tree/tree.vue";

	var testModule = uni.requireNativePlugin("TestModule")

	export default {
		name: "Tree",
		components: {
			uniCollapse,
			uniCollapseItem,
			Tree
		},
		props: {
			dataList: {
				type: Array
			}
		},
		data() {
			return {
				active: null 
			};
		},
		methods: {

			openVideo(data) {
				let requestData = {
					type: 1,
					zbOrHwBillNo: data.id
				}
				this.axios({
					url: '/API/APPCommon/GetSysBoadCamera',
					data: requestData,
					isLoading: true
				}).then(res => {
					let {
						IsSuccess,
						Result
					} = res;
					if (Result.length == 1) {
						this.gotoNativePage(Result[0], data.t)
					} else {
						uni.navigateTo({
							url: '/pages/public/video-list?id=' + data.id
						})
					}
				})
			},


			gotoNativePage(data, name) {
				// id: this.keywordID,
				console.log(getApp().globalData.Token,
					getApp().globalData.BaseURL,
					data.VIDEOTYPE || '3', // 查看类型  1 云台， 2轨迹， 3盘点数量
					data.CameraNo || '', // 摄像头IP
					data.LoginName || '', // 摄像头密码账户
					data.PassWord || '', // 摄像头密码
					data.Port || '', // 摄像头端口
					data.Channel || '0', // 摄像头通道号
					data.VDEF4 || '0', // 录像机IP 
					data.VDEF5 || '', // 录像机账户
					data.VDEF6 || '', // 录像机密码
					data.VDEF7 || '0', // 录像端口
					data.VDEF11 || '0', // 录像机通道号
					'',
					'',
					data.PK_BILLNO || '',
					'',
					'');
				// let newParams = '';
				testModule.gotoNativePage(
					getApp().globalData.Token,
					getApp().globalData.BaseURL,
					data.VIDEOTYPE || '3', // 查看类型  1 云台， 2轨迹， 3盘点数量
					data.CameraNo || '', // 摄像头IP
					data.LoginName || '', // 摄像头密码账户
					data.PassWord || '', // 摄像头密码
					data.Port || '', // 摄像头端口
					data.Channel || '0', // 摄像头通道号
					data.VDEF4 || '0', // 录像机IP 
					data.VDEF5 || '', // 录像机账户
					data.VDEF6 || '', // 录像机密码
					data.VDEF7 || '0', // 录像端口
					data.VDEF11 || '0', // 录像机通道号
					'',
					'',
					name || '',
					'',
					'',
					data.PK_BILLNO || '',
				);
			},

			lastClick(item, i) {
				item.o = item.r != 5 ? !item.o : false;
				console.log(77, item);
				this.active = item
				uni.$emit("lastClick", {
					item: item,
					index: i
				});
			}
		}
	};
</script>

<style lang="scss">
	.uni-collapse-cell.uni-collapse-cell--open {
		border: none;
	}

	.uni-collapse-cell--open {
		background: #fff;
		box-sizing: border-box;
	}

	.text11 {
		display: block;
		height: 48px;
		line-height: 24px;
		box-sizing: border-box;
		padding: 24rpx;
		font-size: 28rpx;
		border-bottom: 0.5px solid $uni-border-color;
		color: red;
	}

	.uni-collapse-cell--open .text11 {
		// padding-left: 48rpx;
	}

	.uni-collapse-cell--open .rr {
		padding-left: 48rpx;
	}
</style>